package recursivecode;

/**
 * 功能描述:反向字符串
 * 2024/07/11
 *
 * @author ZhangYi
 */
public class ReverseString {
	public static void main(String[] args) {
		String str = "abcdefghijklmnopqrstuvwxyz";
		String res = reverseString(str);
		System.out.println("反转后的字符串为"+res);
	}

	private static String reverseString(String str) {
		if (str.length() == 1){
			return str;
		}
		String subString = str.substring(1, str.length());
		String result = reverseString(subString);
		result += str.substring(0, 1);
		return result;
	}
}
